/**
 * @param {number[]} nums
 * @param {number} k
 * @return {void} Do not return anything, modify nums in-place instead.
 */
var rotate = function (nums, k) {
  let tempArr = [];
  let len = nums.length;
  for (let i = 0; i < len; i++) {
    let afterIndex = (i + k) % len;
    console.log(afterIndex);
    tempArr[afterIndex] = nums[i];
  }
  return tempArr;
};

let nums = [-1, -100, 3, 99];
console.log(rotate(nums, 2));
